package com.example.budget3.modify;

import android.content.Intent;
import android.view.MenuItem;
import com.example.budget3.R;

public class WidgetAddTransaction extends AddTransaction{
	
	public static final String KEY_LIST_PREFERENCE = "pref_currency";

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        // Handle action buttons
        switch(item.getItemId()) {
        case R.id.action_save:

        	if(checkFields()){
        		store();
    	    	Intent i = new Intent();
	  	    	  i.setAction(Intent.ACTION_MAIN);
	  	    	  i.addCategory(Intent.CATEGORY_HOME);
	  	    	  startActivity(i); 
	  	    	  finish(); 
	        	return true;
        	}
   
            return false;
         // Respond to the action bar's Up/Home button
	    case android.R.id.home:
	    	Intent i = new Intent();
	    	  i.setAction(Intent.ACTION_MAIN);
	    	  i.addCategory(Intent.CATEGORY_HOME);
	    	  startActivity(i); 
	    	  finish(); 
	    	return true;
        default:
            return super.onOptionsItemSelected(item);
        }
    }
    
    @Override
    public void close() {
    	Intent i = new Intent();
  	  i.setAction(Intent.ACTION_MAIN);
  	  i.addCategory(Intent.CATEGORY_HOME);
  	  startActivity(i); 
  	  finish(); 
 	
    }

}
